<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
  class Players extends CI_Controller {

    function __construct()
    {
       parent::__construct();
         $this->load->library('Auth');
         $this->load->helper('access_helper');
         
         $this->load->library('View');
         $this->view->setlayout('themplates/astyle/layout');
         $this->view->setTheme('themplates/astyle');
         $this->load->model('render_model', 'render');
         
         $this->load->model('Players_model', 'players');
         
       
         
    }
    
    function index()
    {
 
     //Доступно как $title в основном шаблоне
        $this->view->setTitle('Main page');
        $this->render->prepare_view();  
          
        $this->view->render('main');
          

     
           
    }
    
    function login()
    {
        $this->index();
    }
    
    function logout()
    {
        $this->auth->logout();
        redirect ("");
    }
    
    function show_players()
    {
     
     if(!$this->auth->hasAccess('players/show_players', 'view')) {        
        redirect ("");}
     
     //Доступно как $title в основном шаблоне   
     $this->view->setTitle('Players');
     $this->render->prepare_view();  
     $this->view->set("ht_server",  $this->players->set_HT_server()); 
     $this->view->set("content",  $this->players->render_table($this->players->getall()));
     $this->view->set("pagination",  $this->players->pagination());
     $this->view->render('show_players');
    
    }
    
    function player_info($PlayerID='')
    {
        if(!$this->auth->hasAccess('players/show_players', 'view')) {        
        redirect ("");}
     
        
     $PlayerID = $this->security->xss_clean($PlayerID);
     $this->view->setTitle('Player info');
     $this->render->prepare_view();  
     $this->view->set("ht_server",  $this->players->set_HT_server()); 
     $this->view->set("player",  $this->players->getPlayer($PlayerID));
     $this->view->render('player_info');    
    }
    
    function export_info()
    {
        
        if(!$this->auth->hasAccess('players/show_players')) { 
           redirect ("");
       }
        
      //if ($this->input->post('get_export'))
     {
         $this->players->export_to_excel($this->players->getall());
         
         //$this->load->plugin('to_excel');
         //to_excel($this->players->getall()); // filename is optional, without it, the plugin will default to 'exceloutput' 
     }
       
    }
    function image($text='', $angle='')
    {

        $this->load->helper('text_image');
        text_image($text, $angle);
        /*
          $this->load->library('image_lib');
          
          $config['image_library'] = 'gd2';
          $config['source_image'] = './images/imag.jpg';
          $config['dynamic_output'] = 'true';
          $config['wm_text'] = $text;
          $config['wm_type'] = 'text';
          if (!$angle) $angle=0;
          else  $angle=90;
          $config['wm_angel'] = $angle;
          $config['wm_font_path'] = './system/fonts/arial.ttf';
          $config['wm_font_size'] = '12';
          $config['wm_font_color'] = '000000';
          $config['wm_vrt_alignment'] = 'bottom';
          $config['wm_hor_alignment'] = 'center';
          $config['wm_vrt_offset'] = '-'.$config['wm_font_size'];
          $config['wm_padding'] = $config['wm_font_size'];

          $this->image_lib->initialize($config);
          
          //$this->image_lib->crop();
          $this->image_lib->create_text();
          $this->image_lib->clear();*/
       
    }
   
  }
?>
